<link href="<?php echo base_url()?>/style/validationEngine.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="<?php echo base_url()?>script/jquery.validationEngine-<?php echo $this->lang->lang()!=''?$this->lang->lang():'en';?>.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>script/jquery.validationEngine.js"></script>
<div class="middleFront">
    <div class="navigation thirdPageSprite"></div>
    <div class="infoText infoTitle">
        <?php echo lang('write_message_title');?>
    </div>
    <ul class="informationHelp">
        <li>
            <?php echo lang('write_message_explain1');?>
        </li>
        <li>
            <?php echo lang('write_message_explain2');?>
        </li>
    </ul>
    <div class="infoText infoTitle">
        <?php
            
                echo lang('message_write_to');
            
        ?>
    </div>
    <ul class="informationHelp">
        <?php
            foreach ($representatives as $key=>$val) {

        ?>
        <li>
            <?php
                $pretstavnik = "";
                $pretstavnik .= "<b>".$val->rep_name." ".$val->rep_surname."</b>";
                switch ($val->role_id){
                    case 1:
                        $pretstavnik .= ", ".lang('pratenik').".";
                        break;
                    case 2:
                        $pretstavnik .= ", ".lang('sovetnik')." ".lang('message_representative_from_mun')." \"".$this->session->userdata('municipality_name')."\".";
                        break;
                    case 3:
                        $pretstavnik .= ", ".lang('gradonacalnik')." ".lang('message_representative_from_mun')." \"".$this->session->userdata('municipality_name')."\".";
                        break;
                }
                echo $pretstavnik;
            ?>
        </li>
        <?php
            }
        ?>
    </ul>
        <?php
            if(validation_errors()){
        ?>
        <div class="errorMessageDiv">
        <?php
              echo validation_errors();
        ?>
        </div>
        <?php
            }

        ?>
    <div class="formHolder">
        <form method="post" action="<?php echo base_url().$this->lang->lang()."/messages/writeMessage/".$this->uri->segment(4)."/".$this->uri->segment(5);?>" name="messageForm">
            <table width="100%" border="0" class="mainTableFormHolder">
            <tr>
                <td>
                    <table class="leftTable" width="100%">
                        <tr>
                            <td width="45%">
                                <b><?php echo lang('sender_name')?></b>
                                <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"><input type="text" class="stiliziran validate[required]" name="sender_name" id="sender_name" value="<?php echo (isset($sendData['sender_name']))?set_value('sender_name',$sendData['sender_name']):''; ?>"/></td>
                        </tr>
                        <tr>
                            <td width="45%">
                                <b><?php echo lang('sender_address')?></b>
                                <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"><input type="text" class="stiliziran validate[required]" name="sender_address" id="sender_address" value="<?php echo (isset($sendData['sender_address']))?set_value('sender_address',$sendData['sender_address']):''; ?>"/></td>
                        </tr>
                        <tr>
                            <td width="45%">
                                <b><?php echo lang('sender_city')?></b>
                                <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"><input type="text" class="stiliziran validate[required]" name="sender_city" id="sender_city" value="<?php echo (isset($sendData['sender_city']))?set_value('sender_city',$sendData['sender_city']):''; ?>"/></td>
                        </tr>
                        <tr>
                            <td width="45%">
                                <b><?php echo lang('municipality_id')?></b>
                                <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%">
                                <select class="stiliziran validate[required]" name="municipality_id" id="municipality_id">
                                    <option value="">&nbsp;</option>
                                    <?php
                                    foreach ($allMunicipalities as $key=>$val) {
                                        ?>
                                    <option value="<?php echo $val->pkMunicipalityID?>" <?php echo (isset($sendData['municipality_id']))?set_select('municipality_id', $val->pkMunicipalityID, array($sendData['municipality_id'])):''; ?>><?php echo $val->municipality_name?></option>
                                    <?php
                                    }
                                    ?>
                                </select>
                            </td>
                        </tr>
                    </table>
                </td>
                <td>
                    <table class="rightTable">
                        <tr>
                            <td width="45%">
                               <b><?php echo lang('sender_email')?></b>
                               <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"><input class="stiliziran validate[required]" type="text" name="sender_email" id="sender_email" value="<?php echo (isset($sendData['sender_email']))?set_value('sender_email',$sendData['sender_email']):''; ?>"/></td>
                        </tr>
                        <tr>
                            <td width="45%">
                               <b><?php echo lang('sender_confirm_email')?></b>
                               <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                            </td>
                            <td width="55%"><input class="stiliziran validate[required,confirm[sender_email]]" type="text" name="sender_confirm_email" id="sender_confirm_email" value="<?php echo (isset($sendData['sender_confirm_email']))?set_value('sender_confirm_email',$sendData['sender_confirm_email']):''; ?>"/></td>
                        </tr>
                        <tr>
                            <td width="45%">
                               <b><?php echo lang('sender_phone')?></b>
                            </td>
                            <td width="55%"><input class="stiliziran" type="text" name="sender_phone" value="<?php echo (isset($sendData['sender_phone']))?set_value('sender_phone',$sendData['sender_phone']):''; ?>"/></td>
                        </tr>
                        <tr>
                            <td width="45%">
                               &nbsp;
                            </td>
                            <td width="55%">&nbsp;</td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td class="textareaHelper">
                    <b><?php echo lang('message')?></b>
                    <img src="<?php echo base_url()."style/images/musthave.png"?>" alt="<?php echo lang('case_field_required')?>" title="<?php echo lang('case_field_required')?>" />
                </td>
                <td>&nbsp;</td>
            </tr>
            <tr>
                <td colspan="2" class="textareaHelper">
                    <input type="hidden" name="rep_id" value="<?php echo (isset($sendData['rep_id']))?$sendData['rep_id']:'';?>">
                    <input type="hidden" name="role_id" value="<?php echo (isset($sendData['rep_id']))?$sendData['role_id']:'';?>">
                    <textarea name="message" id="message" class="stiliziran textMail validate[required]" cols="45" rows="15"><?php echo (isset($sendData['message']))?set_value('message',$sendData['message']):''; ?></textarea>
                </td>
            </tr>
            <tr>
                <td class="textareaHelper">
                    <div class="returnBack">
                        <a href="<?php echo base_url().$this->lang->lang()."/representatives/pickRepresentative"?>"><?php echo lang('pick_representative')?></a>
                    </div>
                </td>
                <td class="textareaHelper">
                    <div class="previewMessage">
                        <button name="previewMessage" id="preview_message"><?php echo lang('preview_message')?></button>
                    </div>
                </td>
            </tr>
        </table>
        </form>
    </div>
    <div class="cleardiv"></div>
</div>
<script type="text/javascript">
    $(document).ready(function(){
        $("form[name=messageForm]").validationEngine();
    });
    $('#preview_message').click(function(){
        $('form[name=messageForm]').submit();
    });
</script>

